﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ITSTOREBLL;

namespace ITStore.Controllers
{
    public class ThongKeDoanhThuController : Controller
    {
        //
        // GET: /ThongKeDoanhThu/
        private ITStoreEntities db = new ITStoreEntities();
        public ActionResult Index(int? Thang, int? Nam)
        {
            List<SelectListItem> DThang = new List<SelectListItem>();
            DThang.Add(new SelectListItem { Text = "Tất cả", Value = "0" });
            for (int i = 1; i <= 12; i++)
            {
                DThang.Add(new SelectListItem { Text = i.ToString(), Value = i.ToString() });
            }
            ViewBag.Thang = DThang;

            List<SelectListItem> DNam = new List<SelectListItem>();
            DNam.Add(new SelectListItem { Text = "Tất cả", Value = "0" });
            for (int i = 2010; i <= 2050; i++)
            {
                DNam.Add(new SelectListItem { Text = i.ToString(), Value = i.ToString() });
            }
            ViewBag.Nam = DNam;
            if (Thang == 0 && Nam == 0)
            {
                var tk = from t in db.DonHangs
                         select t;
                return View(tk.ToList());
            }
            else
            {
                var tk = from t in db.DonHangs
                         where t.dh_Ngay.Month == Thang && t.dh_Ngay.Year == Nam
                         select t;
                return View(tk.ToList());
            }
        }
    }
}
